package com.tn.rtdata;

import java.io.Serializable;
import java.util.List;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * The unique identity for a fill.
 */
public class FillIdentity implements Serializable
{
  private String name;
  private List<?> parameters;

    /**
   * Creates a new <code>FillIdentity</code>.
   * 
   * @param name       the name of the fill.
   * @param parameters the parameters used to create the fill.
   */
  public FillIdentity(String name, List<?> parameters)
  {
    this.name = name;
    this.parameters = parameters;
  }

  /**
   * Returns the name.
   */
  public String getName()
  {
    return name;
  }

  /**
   * Returns the parameters.
   */
  public List<?> getParameters()
  {
    return parameters;
  }
  
  /**
   * Compares this object to another for equality.  For another object to be considered equal to a <code>FillIdentity</code> the other 
   * object must be a <code>FillIdentity</code> and must have been initialized with the same values.
   *
   * @param other the other object.
   *
   * @return <code>true</code> if the objects are considered equal, otherwise <code>false</code>.
   */
  @Override
  public boolean equals(Object other)
  {
    return this == other || other != null && getClass() == other.getClass() &&
      new EqualsBuilder()
        .append(getName(), ((FillIdentity)other).getName())
        .append(getParameters(), ((FillIdentity)other).getParameters())
        .isEquals();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public int hashCode()
  {
    return new HashCodeBuilder()
      .append(getName())
      .append(getParameters())
      .toHashCode();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
      .append("name", getName())
      .append("parameters", getParameters())
      .toString();
  }
}
